//
//  ByTitleTFView.m
//  recordworktool_ios
//
//  Created by mc on 2017/12/4.
//  Copyright © 2017年 ZhangZhanbin. All rights reserved.
//

#import "ByTitleTFView.h"

@implementation ByTitleTFView

- (id)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if(self){
        
        UILabel *titleLabel = [[UILabel alloc] init];
        [self addSubview:titleLabel];
        [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(self).offset(0);
            make.size.mas_equalTo(CGSizeMake(100, 20));
            make.left.equalTo(self).offset(0);
        }];
        titleLabel.textColor = TEXT_COLOR;
        titleLabel.font = FONT(16);
        titleLabel.textAlignment = NSTextAlignmentCenter;
        titleLabel.text = @"工头";
        
        UITextField *textField = [[UITextField alloc] init];
        [self addSubview:textField];
        [textField mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(titleLabel.mas_right).offset(10);
            make.right.equalTo(self).offset(-20);
            make.centerY.equalTo(self).offset(0);
            make.height.mas_equalTo(@35);
        }];
        textField.layer.borderColor = BY_LINE_COLOR.CGColor;
        textField.layer.borderWidth = 1;
        textField.layer.cornerRadius = 5;
        textField.placeholder = @"从通信录中选择工头";
        textField.font = FONT(14);
        [self setTextFieldLeftPadding:textField forWidth:5];
        
        UIView *rightView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 30, 15)];
        UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 10, 15)];
        imageView.image = [UIImage imageNamed:@"jiyibiyoujiantou"];
        [rightView addSubview:imageView];
        textField.rightView = rightView;
        textField.rightViewMode = UITextFieldViewModeAlways;
       
        self.titleLabel = titleLabel;
        self.textTield = textField;
        
    }
    return self;
}

-(void)setTextFieldLeftPadding:(UITextField *)textField forWidth:(CGFloat)leftWidth
{
    CGRect frame = textField.frame;
    frame.size.width = leftWidth;
    UIView *leftview = [[UIView alloc] initWithFrame:frame];
    textField.leftViewMode = UITextFieldViewModeAlways;
    textField.leftView = leftview;
}

@end
